home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.4)
-
- """
- This module contains code to manage and control the
- installed LSP for SpamExperts. Installing the LSP means
- turning it on using a commandline tool called 'RegisterLSP'.
- The LSP code is a dll in 'WINDOWS\\SYSTEM32' called 'SpamExpertsLSP.dll'
- Configuration is done with a file 'SpamExpertsLSP.ini in the same system
- directory.
- """
- import os
- import sys
- import subprocess
- import win32con
- from spamexperts import resources
-
- class LSPControl(object):
- lib_dir = os.path.join(resources.application_directory(), 'lib')
-
- def installLSP(self):
- if self.isInstalled():
- return None
-
- platform = sys.getwindowsversion()[3]
- if platform == win32con.VER_PLATFORM_WIN32_WINDOWS:
- subprocess.call('RegisterLSP.exe -g -z MS.w95.spi.tcp -z MS.w95.spi.udp -y', shell = True, stdin = subprocess.PIPE, stderr = subprocess.PIPE, stdout = subprocess.PIPE, cwd = self.lib_dir)
- elif platform == win32con.VER_PLATFORM_WIN32_NT:
- subprocess.call('RegisterLSP.exe -g -z MSAFD Tcpip [TCP/IP] -z MSAFD Tcpip [UDP/IP] -y', shell = True, cwd = self.lib_dir)
- else:
- print >>sys.stderr, 'Unsupported Windows version for transparent proxy.'
-
-
- def removeLSP(self):
- if not self.isInstalled():
- return None
-
- subprocess.call('RegisterLSP.exe -q SpamExpertsLSP', stdin = subprocess.PIPE, stderr = subprocess.PIPE, stdout = subprocess.PIPE, shell = True, cwd = self.lib_dir)
-
-
- def getLSPInfo(self):
- return subprocess.Popen('RegisterLSP.exe -p', shell = True, cwd = self.lib_dir, stdin = subprocess.PIPE, stderr = subprocess.PIPE, stdout = subprocess.PIPE).stdout.read()
-
-
- def getLSPShortInfo(self):
-
- try:
- return subprocess.Popen('RegisterLSP.exe -l', shell = True, cwd = self.lib_dir, stdin = subprocess.PIPE, stderr = subprocess.PIPE, stdout = subprocess.PIPE).stdout.read()
- except WindowsError:
- e = None
- print >>sys.stderr, 'Could not check LSP status', str(e)
- return ''
-
-
-
- def isInstalled(self):
- o = self.getLSPShortInfo()
- for l in o.split('\n'):
-
- try:
- (catid, sep, name) = l.split()
- except ValueError:
- continue
-
- if name == 'SpamExpertsLSP':
- return True
- continue
-
- return False
-
-
-